/*
 * main.cpp
 *
 *  Created on: Sep 19, 2011
 *      Author: lindenb
 */
#include "ibdtrace.h"
#include "xstdlib.h"
#include "xzlib.h"
#include "where.h"
using namespace std;


static void usage(const char* app)
	{
	std::cout << app << ". Pierre Lindenbaum PhD\n Compiled on "
			<< __DATE__ << " at " << __TIME__ << "\n";
	std::cout << "Programs:\n"
		   << " * read\n"
		   << " * trace\n"
		   << " * build\n"
		   ;
	}

int main(int argc,char** argv)
	{
	Application* app=NULL;
	if(argc==1) {usage(argv[0]); return EXIT_SUCCESS;};
	if(strcmp(argv[1],"build")==0)
		{
		app=new ApplicationBuilder;
		}
	else if(strcmp(argv[1],"read")==0)
		{
		app=new ApplicationReader;
		}
	else if(strcmp(argv[1],"trace")==0)
		{
		app=new ApplicationTracer;
		}
	if(app==NULL)
		{
		cerr << "Unknown program:" << argv[1] << endl;
		return EXIT_FAILURE;
		}
	return  app->main(argc-1,&argv[1]);
	}
